﻿using MySqlQueryToolkit.DataAccess;

namespace MySqlQueryToolkit
{
    public interface ITimeQueryRepository
    {
        TimeQueryResult GetEntitiesFromDatabase(string query);
    }

    public class TimeQueryRepository : Repository, ITimeQueryRepository
    {
        private readonly IDataAccess _dataAccess;

        public TimeQueryRepository(IDataAccess dataAccess)
        {
            _dataAccess = dataAccess;
        }

        public TimeQueryResult GetEntitiesFromDatabase(string query)
        {
            _dataAccess.CommandText = query;
            return new TimeQueryResult { Milliseconds = _dataAccess.ExecuteTimedQuery() };
        }
    }
}
